/*
 * @lc app=leetcode.cn id=1557 lang=typescript
 *
 * [1557] 可以到达所有点的最少点数目
 */

// @lc code=start
function findSmallestSetOfVertices(n: number, edges: number[][]): number[] {
    const inDegree = new Array(n).fill(0);
    const res: any = [];
    for (let edge of edges) {
        const y = edge[1];
        inDegree[y]++;
    }

    for (let i = 0; i < inDegree.length; i++) {
        if (inDegree[i] === 0) {
            res.push(i);
        }
    }
    return res
};

// @lc code=end

